<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AlterServiceSubAddCps extends Migrator
{
    public function up() {
        // service_sub 系统表 配置不同业务流程 插入数据
        $table = 'service_sub';
        $list = \think\facade\Db::table($table)->where('serv_type', PRODUCT_MOBILE_CPS_SERV)->findOrEmpty();
        if (empty($list)) {
            $data = [
                'serv_type' => PRODUCT_MOBILE_CPS_SERV,
                'name' => 'CPS话费',
                'type_name' => 'CPS话费',
            ];
            \think\facade\Db::name($table)->insert($data);
        }
    }

    public function down() {
        \think\facade\Db::table('service_sub')->where('serv_type',PRODUCT_MOBILE_CPS_SERV)->delete();
    }
}
